package spring.framework.beans.factory.support;

import spring.framework.beans.factory.config.SingletonBeanRegistry;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author fun.pengzh
 * @class spring.framework.beans.factory.support.DefaultSingletonBeanRegistry
 * @desc
 * @since 2021-09-22
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {

    private final Map<String, Object> singletonMap = new ConcurrentHashMap();

    @Override
    public Object getSingleton(String beanName) {
        return singletonMap.get(beanName);
    }

    public void addSingleton(String beanName, Object object) {
        singletonMap.put(beanName, object);
    }
}
